*--------------------------------------------------
* Replication materials for "How Trust in Experts 
* and Media Use Affect Acceptance of Common 
* Anti-Vaccination Claims"
* The Harvard Kennedy School Misinformation Review
*--------------------------------------------------

/* Authors:

Dominik Andrzej Stecula
Annenberg Public Policy Center
University of Pennsylvania 
& Simon Fraser University
Email: dominik.stecula@appc.upenn.edu
ORCID: 0000-0001-6724-7559

Ozan Kuru
Annenberg Public Policy Center
University of Pennsylvania
Email: ozan.kuru@appc.upenn.edu
ORCID: 0000-0002-0485-1705

Kathleen Hall Jamieson
Annenberg Public Policy Center
University of Pennsylvania
Email: kathleen.jamieson@asc.upenn.edu
ORCID: 0000-0002-4167-3688

*/

*--------------------------------------------------
* Program Setup
*--------------------------------------------------
version 15              																		// Version number for backward compatibility
clear all               																		// Start with a clean slate
set more off            																		// Disable partitioned output
macro drop _all         																		// clear all macros

* We use a plotplain scheme for figures

*--------------------------------------------------
* Variables
*--------------------------------------------------

/*
*** Change in measles and MMR exposure variables (T6-T4) ***

gen mmrnews_diff=news_measles-news_measles_t4
gen mmrsocial_diff=social_measles-social_measles_t4


*** Change in vaccine misinformation variables ***

gen antivax_change=antivax_t6-antivax_t4

* Standard deviation of change is .51
* First, a dummy with baseline of 0 and 1 if withint 1+ SD (more misinformed)

gen antivax_more=0
replace antivax_more=1 if antivax_change>.51
replace antivax_more=. if antivax_change< -.51
replace antivax_more=. if antivax_change==.

gen antivax_less=0
replace antivax_less=1 if antivax_change< -.51
replace antivax_less=. if antivax_change>.51
replace antivax_less=. if antivax_change==.


*** Variables were standardized for Figure 2 ***

center female education inc age2 child religiosity trust idlg party conspiracy rw_news lw_news ms_news  ///
mmr_news_t4 mmr_social_t4 mmr_news mmr_social antivax_t4 antivax_t6 news_measles_t4 social_measles_t4 news_measles social_measles, s

* standardized variables start with c_
*/

*--------------------------------------------------
* Figure 1 
*--------------------------------------------------

* use the main dataset
hist antivax_t4, scheme(plotplain) percent bin(11) xtitle("") ytitle("Percent of respondents") ylab(0(10)50) text(50 3 "Vaccine misinformation index", placement(w))
graph save hist1.gph, replace
hist antivax_t6, scheme(plotplain) percent bin(11) xtitle("Vaccine misinformation index") ytitle("Percent of respondents") text(30 3 "September 2019", placement(w))
graph save hist2.gph, replace
graph bar, over(antivax1_t4, label(labsize(small) angle(45))) scheme(plotplain) text(80 100 "Autism", placement(w)) ytitle("Percent of respondents") ylab(0(20)80)
graph save bar1.gph, replace
graph bar, over(antivax2_t4, label(labsize(small) angle(45))) scheme(plotplain) text(80 100 "Toxins", placement(w)) ytitle("Percent of respondents") ylab(0(20)80)
graph save bar2.gph, replace
graph bar, over(antivax3_t4, label(labsize(small) angle(45))) scheme(plotplain) text(80 100 "Delay", placement(w)) ytitle("Percent of respondents") ylab(0(20)80)
graph save bar3.gph, replace
graph bar, over(antivax4_t4, label(labsize(small) angle(45))) scheme(plotplain) text(80 100 "Natural immunity", placement(w)) ytitle("Percent of respondents") ylab(0(20)80)
graph save bar4.gph, replace

graph combine bar1.gph bar2.gph bar3.gph bar4.gph, row(2) ysize(8) xsize(8) ycommon xcommon scheme(plotplain) name(right, replace)	
graph combine right hist1.gph, row(1) ysize(4) xsize(6) scheme(plotplain)


*--------------------------------------------------
* Figure 2
*--------------------------------------------------

* use the main dataset
reg c_antivax_t4 c_female c_education c_inc c_age2 c_child c_religiosity c_trust c_party c_rw_news c_lw_news c_ms_news c_news_measles_t4 c_social_measles_t4 sample
coefplot, xline(0, lc(red) lw(med) lp(solid)) drop(_cons sample) xtitle(Standardized Regression Coefficients) scheme(plotplain) ///
	text(1 0.15 "Adj R²=0.34", size(small)) text(1.5 0.17 "N=2,423", size(small)) msymbol(S)

*--------------------------------------------------
* Figure 3 
*--------------------------------------------------

* use the salience dataset
* News
tsline news, scheme(plotplain) tline(01feb2019 01sep2019)
* Google trends
tsline measles mmr, scheme(plotplain) tline(01feb2019 01sep2019) ///
	legend(col(1) keygap(.8) symxsize(5) symysize(.8) size(small) rowgap(.1) lab(1 "Measles") ///
	lab(2 "MMR") position(11) ring(0) region(lstyle(none) fcolor(none))) 

*--------------------------------------------------
* Figure 4 
*--------------------------------------------------

* use the main dataset
estimates clear
probit antivax_more female education inc age2 religiosity child trust party rw_news lw_news ms_news mmrnews_diff mmrsocial_diff 
estimates store A
probit antivax_less female education inc age2 religiosity child trust party rw_news lw_news ms_news mmrnews_diff mmrsocial_diff 
estimates store B
coefplot (A, label(More misinformed) color(blue) pstyle(p3)) (B, label(Less misinformed) color(green) pstyle(p3)), ///
	xline(0, lc(red) lw(med) lp(solid)) drop(_cons) msymbol(S) ///
	xtitle(Probit Regression Coefficients) scheme(plotplain) ///
	xlab(-.75(.25).75) ///
	legend(col(1) keygap(.8) symxsize(5) symysize(.8) size(small) rowgap(.1) position(7) ring(0) region(lstyle(none) fcolor(none))) ///
	text(12.5 0.50 "Pseudo R²=0.04 N=1,471", color(blue) size(vsmall)) text(13 0.50 "Pseudo R²=0.07 N=1,380", color(green) size(vsmall))
estimates clear


